/// @tags:
#include <cassert>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

using ll = long long;

constexpr int maxn = 2e5;

ll a[maxn + 1];

struct Node {
  int pre = 0, nxt = 0, id;
  ll val;

  bool operator<(const Node &rhs) const { return val < rhs.val; }
} nodes[maxn + 1];

bool del[maxn + 1];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  auto cmp = [](int x, int y) { return nodes[x] < nodes[y]; };
  std::priority_queue<int, std::vector<int>, decltype(cmp)> q(cmp);
  nodes[1].val = a[1];
  nodes[1].id = 1;
  int head = 1;
  for (int i = 2; i <= n; ++i) {
    if (a[i] != a[i - 1]) {
      nodes[i].pre = head;
      nodes[head].nxt = i;
      nodes[i].val = a[i];
      nodes[i].id = i;
      q.push(head);
      head = i;
    } else {
      del[i] = true;
    }
  }
  q.push(head);
#ifdef DEBUG
  cout << "q.size() = " << q.size() << endl;
#endif
  int ans = 0;
  while (q.size() > 1) {
    int cur = q.top();
    q.pop();
    if (del[cur]) {
      cout << "Hey i'm deleted!\n";
      continue;
    }
    ans++;
    nodes[cur].val = sqrtl(nodes[cur].val / 2 + 1);
    bool flag = false;
    while (nodes[cur].pre != 0 && nodes[cur].val == nodes[nodes[cur].pre].val) {
      nodes[nodes[cur].pre].nxt = nodes[cur].nxt;
      if (nodes[cur].nxt != 0) nodes[nodes[cur].nxt].pre = nodes[cur].pre;
      del[cur] = true;
      cur = nodes[cur].pre;
      flag = true;
    }
    while (nodes[cur].nxt != 0 && nodes[cur].val == nodes[nodes[cur].nxt].val) {
      nodes[nodes[cur].nxt].pre = nodes[cur].pre;
      if (nodes[cur].pre != 0) nodes[nodes[cur].pre].nxt = nodes[cur].nxt;
      del[cur] = true;
      cur = nodes[cur].nxt;
      flag = true;
    }
    if (!flag) q.push(cur);
  }
  while (!q.empty()) {
    int cur = q.top();
    cout << del[nodes[cur].id] << ' ';
    cout << nodes[cur].val << ' ';
    cout << nodes[cur].id << ' ';
    q.pop();
  }
  cout << ans << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("砍竹子.in", "r", stdin);
  freopen("砍竹子.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
